<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<%@ Import Namespace="System.Web.Mail" %>


<html>
<head>
<!--------------------------------------------------------------------------->

<script language="VB" runat=server>

  Sub Page_Load(Source As Object, E As EventArgs) 
    
    Dim myConnection As SQLConnection
    Dim ConnStr      As String
    Dim i            As Integer
    Dim x            As Integer
    Dim y            As Integer

    ' set the connection details
    ConnStr = "Server=localhost; database=_pubs; UID=sa"

    Try
      myConnection = New SQLConnection(ConnStr)
      myConnection.Open()

      i = x / y

    Catch exSQL As SQLException
      SendMail(exSQL.ToString())

    Catch ex As Exception
      SendMail(ex.ToString())


    Finally

    End Try

  End Sub


  Public Sub SendMail(message As String)

    Dim MyMessage as New MailMessage

    MyMessage.To = "davids@ipona.co.uk"
    MyMessage.From = "davids@ipona.co.uk"
    MyMessage.Subject = "Unhandled ASP.NET Error"
    MyMessage.BodyFormat = MailFormat.Text

    MyMessage.Body = message

    SmtpMail.Send(MyMessage)

    End Sub

</script>


</html>